package com.zhentao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhentao.pojo.WorkflowTask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 流程任务Mapper接口
 */
@Mapper
public interface WorkflowTaskMapper extends BaseMapper<WorkflowTask> {
    
    /**
     * 根据处理人ID查询待办任务
     */
    @Select("SELECT * FROM workflow_task WHERE assignee_id = #{assigneeId} AND status = 0 ORDER BY start_time DESC")
    List<WorkflowTask> selectTodoTasksByAssignee(Long assigneeId);
    
    /**
     * 根据处理人ID查询已办任务
     */
    @Select("SELECT * FROM workflow_task WHERE assignee_id = #{assigneeId} AND status = 1 ORDER BY end_time DESC")
    List<WorkflowTask> selectDoneTasksByAssignee(Long assigneeId);
    
    /**
     * 根据单据信息查询任务
     */
    @Select("SELECT * FROM workflow_task WHERE bill_type = #{billType} AND bill_id = #{billId} ORDER BY start_time")
    List<WorkflowTask> selectByBill(String billType, Long billId);
} 